package cn.t.vo.user;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.List;

/**
 * @author l
 */
@Data
public class
UserSessionVO implements Serializable {

    private String token;

    private Integer scenarioId;

    private Long passportId;

    private Long userId;

    private PassportVO passportVO;

    private IndividualVO individualVO;

    private List<FirmVO> firms;

    private Long deceiveId;

    private MySaTokenInfoVO mySaTokenInfoVO;

    public String firmId() {
        if (firmInfo() == null) {
            return null;
        }
        return firmInfo().getFirmName();
    }

    public FirmVO firmInfo() {
        if (CollectionUtils.isEmpty(firms)) {
            return null;
        }

        return firms.get(0);
    }

    public String operatorInfo() {
        String ret = "";
        if (userId != null) {
            ret = String.valueOf(userId);
        }

        if (individualVO != null && StringUtils.isNotBlank(individualVO.getCustomerName())) {
            ret += " " + individualVO.getCustomerName();
        }

        if (StringUtils.isBlank(ret)) {
            ret = "system";
        }

        return ret;
    }

}
